﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using App.Core.Extensions;
using App.Data;
using System.Data;

public partial class Pages_Private_ProjectList : BasePage
{
    private const int PROJECT_LIST_SIZE = 25;

    protected void Page_Load(object sender, EventArgs e)
    {
        BindPageInfo();
        if (!IsPostBack)
        {
            BindProjectList(1);
        }
    }
    protected void BindPageInfo()
    {
        Page.Title = WebUtil.GetPageTitle("Project List");
    }
    protected void BindProjectList(int pageNumber)
    {
        int totalRecord = 0;
        UtilityDAO dao = new UtilityDAO();
        DbParameter[] parameters = new[] { new DbParameter("@CustomerID", SessionCache.CurrentUser.CustomerID) };
        DataSet ds = dao.GetPagedData(AppSQL.GET_PAGED_PROJECTS_BY_CUSTOMER, parameters, pageNumber, PROJECT_LIST_SIZE, out  totalRecord);
        ucProjectList.DataSource = ds.Tables[0];
        ucProjectList.EditLink = AppConstants.Pages.PROJECT_LIST_BY_CUSTOMER + "?" + AppConstants.QueryString.ID + "={0}";
        ucProjectList.DeleteLink = AppConstants.Pages.PROJECT_LIST_BY_CUSTOMER + "?" + AppConstants.QueryString.ID + "={0}&" + AppConstants.QueryString.DELETE + "=True";
        ucProjectList.LinkFields = "ID";
        ucProjectList.DataBind();
    }
}